package com.ithuameng.admin.enums;

import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonCreator.Mode;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * Menu type enum
 *
 * @author ithuameng
 */
@Getter
public enum MenuType implements IEnum<String>, AdminEnumStrValue {

    /**
     * 目录
     */
    DIR("M"),

    /**
     * 菜单
     */
    MENU("C"),

    /**
     * 按钮
     */
    BUTTON("F");

    MenuType(String value) {
        this.value = value;
    }

    @JsonValue
    private String value;

    @JsonCreator(mode = Mode.DELEGATING)
    public static MenuType forValue(String value) {
        MenuType[] enums = MenuType.values();
        for (MenuType e : enums) {
            if (e.getValue().equals(value)) {
                return e;
            }
        }
        return null;
    }
}
